package com.tomowork.utils;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;

import org.joda.time.format.DateTimeFormatter;
import java.util.Date;

public class DateUtil {
    public static final String FORMATE = "yyyy-MM-dd HH:mm:ss SS" ;
    private static DateTimeFormatter formatter = DateTimeFormat.forPattern(FORMATE) ;
    //将字符串转换成时间类型
    public static Date str2Date(String dateStr){
        DateTime datatime = DateTime.parse(dateStr,formatter);
        return datatime.toDate() ;

    }
    //将时间转换成字符串类型
    public static String date2Str(Date date){
        DateTime dateTime = new DateTime(date);
        return dateTime.toString(FORMATE) ;
    }
}
